

//
//  CustomTableViewCell.m
//  UI14_HomeWork_豆瓣
//
//  Created by Bodi on 16/6/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CustomTableViewCell.h"
#import "ActivityModel.h"
#import "UIImageView+WebCache.h"
@interface CustomTableViewCell()

@property (nonatomic, retain) UILabel *titileLabel;
@property (nonatomic, retain) UILabel *timeLabel;
@property (nonatomic, retain) UILabel *addressLabel;
@property (nonatomic, retain) UILabel *typeLabel;
@property (nonatomic, retain) UIImageView *bodiImage;
@property (nonatomic, retain) UILabel *interestedLabel;
@property (nonatomic, retain) UILabel *participateLabel;


@end



@implementation CustomTableViewCell

- (void)dealloc{
    [_titileLabel release];
    [_timeLabel release];
    [_addressLabel release];
    [_typeLabel release];
    [_bodiImage release];
    [_interestedLabel release];
    [_participateLabel release];
    [super dealloc];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.titileLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.titileLabel];
        [_titileLabel release];
        
        self.timeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.timeLabel];
        [_timeLabel release];
        
        self.addressLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.addressLabel];
        [_addressLabel release];
        
        self.typeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.typeLabel];
        [_typeLabel release];
        
        self.bodiImage = [[UIImageView alloc]init];
        [self.contentView addSubview:self.bodiImage];
        [_bodiImage release];
        
        self.interestedLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.interestedLabel];
        [_interestedLabel release];
        
        self.participateLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.participateLabel];
        [_participateLabel release];
        
    }
    return self;
}

- (void)layoutSubviews{

    self.titileLabel.frame = CGRectMake(10, 20, self.contentView.bounds.size.width, 30);
    self.titileLabel.backgroundColor = [UIColor colorWithRed:0.81f green:0.87f blue:0.89f alpha:1.00f];;
    
    UIImage *image1 = [UIImage imageNamed:@"icon_date_blue@2x.png"];
    UIImageView *view1 = [[UIImageView alloc]initWithImage:image1];
    view1.frame = CGRectMake(10, 60, 25, 25);
    [self.contentView addSubview:view1];
    self.timeLabel.frame = CGRectMake(33, 60, self.contentView.bounds.size.width / 5 * 3, 20);
//    self.timeLabel.backgroundColor = [UIColor yellowColor];
    
    UIImage *image2 = [UIImage imageNamed:@"icon_spot_blue@2x.png"];
    UIImageView *view2 = [[UIImageView alloc]initWithImage:image2];
    view2.frame = CGRectMake(10, 90, 25, 25);
    [self.contentView addSubview:view2];

    self.addressLabel.frame = CGRectMake(33, 90, self.contentView.bounds.size.width / 5 * 3, 20);
//    self.addressLabel.backgroundColor = [UIColor greenColor];
    
    
    
    UIImage *image3 = [UIImage imageNamed:@"icon_catalog_blue@2x.png"];
    UIImageView *view3 = [[UIImageView alloc]initWithImage:image3];
    view3.frame = CGRectMake(10, 120, 25, 25);
    [self.contentView addSubview:view3];
    self.typeLabel.frame = CGRectMake(33, 120, self.contentView.bounds.size.width / 5 * 3, 20);
//    self.typeLabel.backgroundColor = [UIColor purpleColor];
    self.bodiImage.frame = CGRectMake(self.contentView.bounds.size.width / 5 * 3 + 40, 55, self.contentView.bounds.size.width / 5 * 1 + 30, 150);
//    self.typeLabel.backgroundColor = [UIColor cyanColor];
    self.interestedLabel.frame = CGRectMake(10, 150, self.contentView.bounds.size.width / 4 * 1, 20);
//    self.typeLabel.backgroundColor = [UIColor greenColor];
    self.participateLabel.frame = CGRectMake(10 + self.contentView.bounds.size.width / 4 * 1, 150, self.contentView.bounds.size.width / 4 * 1, 20);
//    self.participateLabel.backgroundColor = [UIColor purpleColor];




}
- (void)setModel:(ActivityModel *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    self.titileLabel.text = model.title;
    self.timeLabel.text = [NSString stringWithFormat:@"%@ -- %@", model.begin_time, model.end_time];
    self.addressLabel.text = model.address;
//    self.typeLabel.text = model.category_name;
    self.typeLabel.text = [NSString stringWithFormat:@"类型: %@",model.category_name];
    NSURL *url = [NSURL URLWithString:model.image];
    [_bodiImage sd_setImageWithURL:url];
    self.interestedLabel.text = [NSString stringWithFormat:@"感兴趣: %@",model.wisher_count];
    self.interestedLabel.textColor = [UIColor redColor];
    self.participateLabel.text = [NSString stringWithFormat:@"参加: %@", model.participant_count];
    self.participateLabel.textColor = [UIColor redColor];
    


}









@end
